Provide a way to disable use of extern templates in libc++. This is intended for the clients of libc++, not the libc++ build. The dylib should always contain the extern templates. To disable the client needs to put -D'_LIBCPP_EXTERN_TEMPLATE(...)=' on the command line. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@167486 91177308-0d34-0410-b5e6-96231b3b80d8 
diff --git a/include/__config b/include/__config index 4e69964..2bbe1d9 100644 --- a/include/__config +++ b/include/__config 
@@ -427,6 +427,10 @@  #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)  #endif // _LIBCPP_HAS_NO_STRONG_ENUMS   +#ifndef _LIBCPP_EXTERN_TEMPLATE +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; +#endif +  #if __APPLE__ || __FreeBSD__ || _WIN32 || __sun__  #define _LIBCPP_LOCALE__L_EXTENSIONS 1  #endif 
diff --git a/include/__locale b/include/__locale index e6c357f..4176720 100644 --- a/include/__locale +++ b/include/__locale 
@@ -254,8 +254,8 @@  return static_cast<long>(__h);  }   -extern template class _LIBCPP_VISIBLE collate<char>; -extern template class _LIBCPP_VISIBLE collate<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_VISIBLE collate<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_VISIBLE collate<wchar_t>)    // template <class CharT> class collate_byname;   @@ -1135,10 +1135,10 @@  {  }   -extern template class codecvt_byname<char, char, mbstate_t>; -extern template class codecvt_byname<wchar_t, char, mbstate_t>; -extern template class codecvt_byname<char16_t, char, mbstate_t>; -extern template class codecvt_byname<char32_t, char, mbstate_t>; +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<wchar_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char16_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char32_t, char, mbstate_t>)    _LIBCPP_VISIBLE void __throw_runtime_error(const char*);   
diff --git a/include/algorithm b/include/algorithm index 1ce14b4..0f6107b 100644 --- a/include/algorithm +++ b/include/algorithm 
@@ -3782,39 +3782,39 @@  #pragma warning( push )  #pragma warning( disable: 4231)  #endif // _MSC_VER -extern template void __sort<__less<char>&, char*>(char*, char*, __less<char>&); -extern template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); -extern template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); -extern template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); -extern template void __sort<__less<short>&, short*>(short*, short*, __less<short>&); -extern template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); -extern template void __sort<__less<int>&, int*>(int*, int*, __less<int>&); -extern template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); -extern template void __sort<__less<long>&, long*>(long*, long*, __less<long>&); -extern template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); -extern template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); -extern template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); -extern template void __sort<__less<float>&, float*>(float*, float*, __less<float>&); -extern template void __sort<__less<double>&, double*>(double*, double*, __less<double>&); -extern template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<char>&, char*>(char*, char*, __less<char>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<short>&, short*>(short*, short*, __less<short>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<int>&, int*>(int*, int*, __less<int>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long>&, long*>(long*, long*, __less<long>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<float>&, float*>(float*, float*, __less<float>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<double>&, double*>(double*, double*, __less<double>&)) +_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))   -extern template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&); -extern template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); -extern template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); -extern template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); -extern template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&); -extern template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); -extern template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&); -extern template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); -extern template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&); -extern template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); -extern template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); -extern template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); -extern template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&); -extern template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&); -extern template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&)) +_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))   -extern template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&); +_LIBCPP_EXTERN_TEMPLATE(unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&))  #ifdef _MSC_VER  #pragma warning( pop )  #endif // _MSC_VER 
diff --git a/include/istream b/include/istream index 7b48186..dc1c52b 100644 --- a/include/istream +++ b/include/istream 
@@ -1710,9 +1710,9 @@  return __is;  }   -extern template class basic_istream<char>; -extern template class basic_istream<wchar_t>; -extern template class basic_iostream<char>; +_LIBCPP_EXTERN_TEMPLATE(class basic_istream<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_istream<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class basic_iostream<char>)    _LIBCPP_END_NAMESPACE_STD   
diff --git a/include/locale b/include/locale index 0d77a4a..72b4729 100644 --- a/include/locale +++ b/include/locale 
@@ -692,8 +692,8 @@  return 0;  }   -extern template struct __num_get<char>; -extern template struct __num_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(struct __num_get<char>) +_LIBCPP_EXTERN_TEMPLATE(struct __num_get<wchar_t>)    template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >  class _LIBCPP_VISIBLE num_get @@ -1314,8 +1314,8 @@  return __b;  }   -extern template class num_get<char>; -extern template class num_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class num_get<char>) +_LIBCPP_EXTERN_TEMPLATE(class num_get<wchar_t>)    struct __num_put_base  { @@ -1464,8 +1464,8 @@  __op = __ob + (__np - __nb);  }   -extern template struct __num_put<char>; -extern template struct __num_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(struct __num_put<char>) +_LIBCPP_EXTERN_TEMPLATE(struct __num_put<wchar_t>)    template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >  class _LIBCPP_VISIBLE num_put @@ -1938,8 +1938,8 @@  return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);  }   -extern template class num_put<char>; -extern template class num_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class num_put<char>) +_LIBCPP_EXTERN_TEMPLATE(class num_put<wchar_t>)    template <class _CharT, class _InputIterator>  _LIBCPP_HIDDEN @@ -2605,8 +2605,8 @@  return __b;  }   -extern template class time_get<char>; -extern template class time_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class time_get<char>) +_LIBCPP_EXTERN_TEMPLATE(class time_get<wchar_t>)    class __time_get  { @@ -2688,8 +2688,8 @@  virtual const string_type& __X() const {return this->__X_;}  };   -extern template class time_get_byname<char>; -extern template class time_get_byname<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class time_get_byname<char>) +_LIBCPP_EXTERN_TEMPLATE(class time_get_byname<wchar_t>)    class __time_put  { @@ -2801,8 +2801,8 @@  return _VSTD::copy(__nb, __ne, __s);  }   -extern template class time_put<char>; -extern template class time_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class time_put<char>) +_LIBCPP_EXTERN_TEMPLATE(class time_put<wchar_t>)    template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >  class _LIBCPP_VISIBLE time_put_byname @@ -2822,8 +2822,8 @@  ~time_put_byname() {}  };   -extern template class time_put_byname<char>; -extern template class time_put_byname<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class time_put_byname<char>) +_LIBCPP_EXTERN_TEMPLATE(class time_put_byname<wchar_t>)    // money_base   @@ -2885,10 +2885,10 @@  locale::id  moneypunct<_CharT, _International>::id;   -extern template class moneypunct<char, false>; -extern template class moneypunct<char, true>; -extern template class moneypunct<wchar_t, false>; -extern template class moneypunct<wchar_t, true>; +_LIBCPP_EXTERN_TEMPLATE(class moneypunct<char, false>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct<char, true>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct<wchar_t, true>)    // moneypunct_byname   @@ -2942,10 +2942,10 @@  template<> void moneypunct_byname<wchar_t, false>::init(const char*);  template<> void moneypunct_byname<wchar_t, true>::init(const char*);   -extern template class moneypunct_byname<char, false>; -extern template class moneypunct_byname<char, true>; -extern template class moneypunct_byname<wchar_t, false>; -extern template class moneypunct_byname<wchar_t, true>; +_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<char, false>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<char, true>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<wchar_t, true>)    // money_get   @@ -3001,8 +3001,8 @@  }  }   -extern template class __money_get<char>; -extern template class __money_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class __money_get<char>) +_LIBCPP_EXTERN_TEMPLATE(class __money_get<wchar_t>)    template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >  class _LIBCPP_VISIBLE money_get @@ -3383,8 +3383,8 @@  return __b;  }   -extern template class money_get<char>; -extern template class money_get<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class money_get<char>) +_LIBCPP_EXTERN_TEMPLATE(class money_get<wchar_t>)    // money_put   @@ -3558,8 +3558,8 @@  __mi = __mb;  }   -extern template class __money_put<char>; -extern template class __money_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class __money_put<char>) +_LIBCPP_EXTERN_TEMPLATE(class __money_put<wchar_t>)    template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >  class _LIBCPP_VISIBLE money_put @@ -3715,8 +3715,8 @@  return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);  }   -extern template class money_put<char>; -extern template class money_put<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class money_put<char>) +_LIBCPP_EXTERN_TEMPLATE(class money_put<wchar_t>)    // messages   @@ -3825,8 +3825,8 @@  #endif // !_WIN32  }   -extern template class messages<char>; -extern template class messages<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class messages<char>) +_LIBCPP_EXTERN_TEMPLATE(class messages<wchar_t>)    template <class _CharT>  class _LIBCPP_VISIBLE messages_byname @@ -3849,8 +3849,8 @@  ~messages_byname() {}  };   -extern template class messages_byname<char>; -extern template class messages_byname<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class messages_byname<char>) +_LIBCPP_EXTERN_TEMPLATE(class messages_byname<wchar_t>)    template<class _Codecvt, class _Elem = wchar_t,  class _Wide_alloc = allocator<_Elem>, 
diff --git a/include/ostream b/include/ostream index b135ddb..9d26a41 100644 --- a/include/ostream +++ b/include/ostream 
@@ -1287,8 +1287,8 @@  use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));  }   -extern template class basic_ostream<char>; -extern template class basic_ostream<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class basic_ostream<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_ostream<wchar_t>)    _LIBCPP_END_NAMESPACE_STD   
diff --git a/include/streambuf b/include/streambuf index e34ad23..d688024 100644 --- a/include/streambuf +++ b/include/streambuf 
@@ -553,11 +553,11 @@  return traits_type::eof();  }   -extern template class basic_streambuf<char>; -extern template class basic_streambuf<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class basic_streambuf<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_streambuf<wchar_t>)   -extern template class basic_ios<char>; -extern template class basic_ios<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class basic_ios<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_ios<wchar_t>)    _LIBCPP_END_NAMESPACE_STD   
diff --git a/include/string b/include/string index 00016ee..5bf42f0 100644 --- a/include/string +++ b/include/string 
@@ -1031,7 +1031,7 @@  #pragma warning( push )  #pragma warning( disable: 4231 )  #endif // _MSC_VER -extern template class __basic_string_common<true>; +_LIBCPP_EXTERN_TEMPLATE(class __basic_string_common<true>)  #ifdef _MSC_VER  #pragma warning( pop )  #endif // _MSC_VER @@ -3975,8 +3975,8 @@    #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES   -extern template class basic_string<char>; -extern template class basic_string<wchar_t>; +_LIBCPP_EXTERN_TEMPLATE(class basic_string<char>) +_LIBCPP_EXTERN_TEMPLATE(class basic_string<wchar_t>)    extern template  string 
diff --git a/include/valarray b/include/valarray index 4091d0f..c56dd12 100644 --- a/include/valarray +++ b/include/valarray 
@@ -4770,9 +4770,9 @@  return __v.__end_;  }   -extern template valarray<size_t>::valarray(size_t); -extern template valarray<size_t>::~valarray(); -extern template void valarray<size_t>::resize(size_t, size_t); +_LIBCPP_EXTERN_TEMPLATE(valarray<size_t>::valarray(size_t)) +_LIBCPP_EXTERN_TEMPLATE(valarray<size_t>::~valarray()) +_LIBCPP_EXTERN_TEMPLATE(void valarray<size_t>::resize(size_t, size_t))    _LIBCPP_END_NAMESPACE_STD   
diff --git a/include/vector b/include/vector index ee71435..0c28068 100644 --- a/include/vector +++ b/include/vector 
@@ -313,7 +313,7 @@  #pragma warning( push )  #pragma warning( disable: 4231 )  #endif // _MSC_VER -extern template class __vector_base_common<true>; +_LIBCPP_EXTERN_TEMPLATE(class __vector_base_common<true>)  #ifdef _MSC_VER  #pragma warning( pop )  #endif // _MSC_VER